<template>
  <div style="display: flex;flex-direction: column;height: 100%">
    <div style="flex: 1;overflow-y: auto">
      <div v-for="(i, index) in dataObject" style="display: flex">
        <div style="height: 99px;line-height: 99px;">
          <input type="checkbox" :value="i.rltOrderId" @click="handleInputChange">
        </div>
        <Cell  :value="`${(i.orderActFee/100).toFixed(2)}元`" style="flex: 1">
          <p slot="title">{{i.plName}}</p>
          <p slot="title">{{i.carNumber}}</p>
          <p slot="title">{{i.name}}</p>
          <p slot="title">{{i.payFinishTime | formatTime}}</p>
        </Cell>
      </div>

    </div>

    <mt-button type="primary" size="large" :disabled="disableFlag"
               @click="billHandle()">
      申请开票
    </mt-button>


  </div>
</template>

import { applyInvoice } from "@/api/bill/bill";
<script>
export default {
  name: 'cardList',
  data() {
    return {
      dataObject: {},
      status: '请开票',
      disableFlag: false,
      selectedData:[]
    }
  },
  computed: {

  },
  mounted() {
    this.dataObject = JSON.parse(sessionStorage.getItem('hasBuyCardInfo'))
    console.log(this.dataObject)
  },
  methods: {
    handleInputChange:function(e){
      console.log("------------");
      console.log(this.selectedData);
      setTimeout(() => {
        if (this.selectedData.indexOf(e.target._value) > -1) {
          this.remove(this.selectedData, e.target._value);
        } else {
          this.selectedData.push(e.target._value);
        }
      }, 0);
      console.log(this.selectedData);
    },
    //数组删除
    remove(arr, val) {
      var index = arr.indexOf(val);
      if (index > -1) {
        arr.splice(index, 1);
      }
    },
    billHandle: function() {
      if(this.selectedData.length == 0){
        this.$msgbox('温馨提示', '请至少选择一条记录！')
      }else{
            this.$router.push({
              path: 'bill',
              query: {
                custId: this.$route.query.color,// 车牌颜色
                carNumber: this.$route.query.car,
                rltOrderIds:JSON.stringify(this.selectedData)
              }
            })
      }
    },
    // billHandle: function (val) {
    //   if(val==10){
    //     this.$router.push({
    //       path: 'bill',
    //       query: {
    //         custId: this.dataObject.custId,// 车牌颜色
    //         carNumber: this.dataObject.carNumber
    //       }
    //     })
    //   }
    //
    //   if(val==30){
    //     this.$msgbox('温馨提示', '您已开票完成，更多发票详情，请致电 010-66020580.')
    //     // this.$toast({
    //     //   message: '您已开票完成，更多发票详情，请致电 010-66020580.',
    //     //
    //     //   duration: 3000,
    //     //   position: 'top'
    //     // })
    //   }
    //
    // }
  }
}
</script>

<style scoped lang="scss">
  .cardWrap {
    width: 95%;
    height: 230px;
    margin: 0 auto;
    padding: 60px 0 0 30px;
    background: url("../assets/images/cardBG.png") no-repeat;
    background-size: 100% 100%;
    color: #FFF;
    font-size: 18px;
    li {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
  }
</style>
